package com.example.springboot.mapper;

import com.example.springboot.bean.Bbs;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface BbsMapper {

    @Select("select * from hyfc_bbs order by id desc limit 0, 16")
    List<Map<?,?>> selectTop();

    @Select("select * from hyfc_bbs where id = #{id}")
    Map<?,?> selectById(int id);

    // 注解实现 组合条件查询
    @Select("<script>" +
            "select * from hyfc_bbs" +
            "<where>" +
            "<if test='type!=null'> type = #{type}</if>" +
            "<if test='title!=null'> and title like concat('%',#{title},'%')</if>" +
            "</where>" +
            "order by id desc" +
            "</script>")
    List<Bbs> selectByObj(Bbs bbs);


}
